<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
</head>

<body>
	<script>
		var wsServer = 'ws://122.51.11.209:9604';
		var websocket = new WebSocket(wsServer);
		
		websocket.onopen = function (evt) {
			console.log("Connected to WebSocket server.");
			//发送消息
			websocket.send("我发送的消息");
		};

		websocket.onclose = function (evt) {
			console.log("Disconnected");
		};

		websocket.onmessage = function (evt) {
			console.log('Retrieved data from server: ' + evt.data);
		};

		websocket.onerror = function (evt, e) {
			console.log('Error occured: ' + evt.data);
		};
	</script>
</body>
<html>